<?php
session_start();
/*
 * Session variables:
 * $_SESSION['type'] [string] = user type of the logged in user
 * $_SESSION['authorised'] [boolean] = whether or not the current user is logged in
 */
if(isset($_SESSION['authorised']) && $_SESSION['authorised'] == true)
{   
    if(isset($_SESSION['type']))
    {
        if($_SESSION['type'] == 'administrator')
        {
           ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Feedback</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<style>
.nav { 
	  width:210px;
	  height:auto;
	  border:thin solid #09C;
	  margin-left: 10px;
	  text-align : center;}
	  
.mainline { 
	  width:712px;
	  height:auto;
	  text-align : center;}


</style></head>
<center>
<body bgcolor="#FFFFFF">
<body>

<div id="wrapper">
	<div id="header">
    <h1></h1>
    </div>
    
    <div id="header2">
    	<h3></h3>
 	</div>
  
	<div id="nav">
    <?php include 'admin_navigation.php';?>
    </div>
	
    <div id="mainline">
        <h4>Ratings for Tutor</h4>
    

  <div id="body">
  <form action=admin_tutorratings.php method=POST>	
    <table width="700" height="auto" cellpadding="3" cellspacing="1" align="center">
        <tr height="40" bgcolor="LightSteelBlue">
            <th>Tutor</th>
            <th>Audibility</th>
            <th>Manner of Teaching</th>
            <th>Materials Used</th>
            <th>Preparedness</th>
            <th>Subject Mastery</th>
        </tr>
        <?php 
       		$action_string = $_POST['action'];
			$action_parts = explode(" ", $action_string);
			$action =  $action_parts[0];
			$teacher_id = $action_parts[1];
			
            include ('connection.inc');
            
            $sql = "SELECT tutor_evaluations.audibility,tutor_evaluations.preparedness, tutor_evaluations.manner_of_teaching, tutor_evaluations.subject_mastery, tutor_evaluations.materials_used, tutor_evaluations.teacher_id, users.lastname, users.firstname from tutor_evaluations natural join teachers natural join users where teacher_id='$teacher_id'";
            $result = pg_query($sql);
            
            $count = pg_num_rows($result);
             if($count<1)
            {
            	echo "</table>";
            	echo "<br>No ratings.";
            }
            else
            {
	            for($i = 0; $i < $count; $i++)
	            {
		            $audibility= pg_fetch_result($result, $i, 'audibility');
		            $manner_of_teaching= pg_fetch_result($result, $i, 'manner_of_teaching');
		            $subject_mastery= pg_fetch_result($result, $i, 'subject_mastery');
		            $materials_used= pg_fetch_result($result, $i, 'materials_used');
		            $preparedness= pg_fetch_result($result, $i, 'preparedness');
	            	$tutor_lastname = pg_fetch_result($result, $i, 'lastname');
	               $tutor_firstname = pg_fetch_result($result, $i, 'firstname');
	                echo "<tr bgcolor=\"#f5f5f5\"><td><center>$tutor_lastname, $tutor_firstname</center></td>
	                <td align=\"center\">$audibility</td>
	                <td align=\"center\">$manner_of_teaching</td>
	                <td align=\"center\">$subject_mastery</td>
	                <td align=\"center\">$materials_used</td>
	                <td align=\"center\">$preparedness</td>
	                
	                </tr>";
	            }
            	echo "</table>";
            }
			?>
	
      <p align="justify"><br />
      </p>
    </div>
    
    <br class="clearfloat">
	<br />
    </div>
    <div id="footer">
    <p align="center">
    Tutorial Business Manager: info@tbms.com <br />Credits/Engineers: Aquino, Chloebelle; Dela Cruz, Roy Erwin; Maliwanag, Ranyel Bryan; Manzano, Audrey Ann; Ng, Sheila Regine<br />
    <br />copyright 2011</p>
    </div>
</div>
</body>
</html>            
           <?php 

        }
        elseif($_SESSION['type'] == 'student')
         {
            header('Location: student_index.php');
            exit();
        }
        elseif($_SESSION['type'] == 'tutor')
        {
            header('Location: tutor_index.php');
            exit();
        }
        elseif($_SESSION['type'] == 'parent')
        {
            header('Location: parent_index.php');
            exit();
        }
    }
}
else
{
    header('Location: index.php');
}
?>

